package io;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        InputStream in = new FileInputStream("test.txt");
        ObjectInputStream inputStream = new ObjectInputStream(in);
        Object obj = inputStream.readObject();
        if (obj instanceof Person) {
            Person p = (Person) obj;
            System.out.println(p);
        }
        inputStream.close();
        in.close();
    }
}
